package ca.mcgill.mni.bic;

import java.sql.Date;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Study {
	Integer tarchiveID;
	String studyUID;
	String studyDescription;
	Date studyDate;
	String patientName;
	String patientID;
	String patientSex;
	Date patientDoB;
	List<Series> series;
	String archiveLocation;
	
	public Study() {
		series = new LinkedList<Series>();
	}
	
	public static boolean isValidPatientName(String name) {
		Config config = Config.singleton();
		for (Pattern pattern : config.patientNamePatterns) {
			Matcher matcher = pattern.matcher(name);
			if(matcher.matches())
				return true;
		}
		
		return false;
	}
	
	public String getPath() {
		return archiveLocation;
	}

	@Override
	public String toString() {
		String s = "Study: \n";
		s += "TarchiveID: " + tarchiveID + "\n";
		s += "StudyUID: " + studyUID + "\n";
		s += "Patient Name: " + patientName + "\n";
		s += "Patient ID: " + patientID + "\n";
		s += "Patient Sex: " + patientSex + "\n";
		s += "Patient DoB: " + patientDoB + "\n";
		s += "Study Date: " + studyDate + "\n";
		
		for (Series curSeries : series) {
			s += curSeries;
		}
		
		return s;
	}
}
